package com.exam.api.modules.system.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.hutool.core.lang.tree.Tree;
import com.exam.api.common.dto.KeywordDTO;
import com.exam.api.common.web.TinyResponse;
import com.exam.api.modules.system.domain.TblDept;
import com.exam.api.modules.system.dto.DeptQueryDTO;

import com.exam.api.modules.system.service.TblDeptService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * (客户端) 部门相关接口
 *
 * @author bcheng
 */
@Tag(name = "(客户端) 部门相关接口", description = "(客户端) 部门相关接口")
@RestController
@RequestMapping("/dept")
@SaCheckLogin
@TinyResponse
public class DeptController {

    @Resource
    private TblDeptService tblDeptService;

    @Operation(summary = "获取部门树", description = "获取部门树")
    @PostMapping("/tree")
    public List<Tree<Long>> treeDept(@RequestBody KeywordDTO dto) {
        return tblDeptService.treeDept(dto);
    }

    @Operation(summary = "获取部门信息", description = "获取部门信息")
    @PostMapping("/list")
    public List<TblDept> listDept(@RequestBody @Validated DeptQueryDTO dto) {
        return tblDeptService.listDept(dto);
    }
}
